﻿<Page
    x:Name="PageRoot"
    x:Class="ShareTargetExample.AllFormatsShareTargetPage"
    DataContext="{Binding DefaultViewModel, RelativeSource={RelativeSource Self}}"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="using:ShareTargetExample"
    xmlns:common="using:ShareTargetExample.Common"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    d:ExtensionType="ShareTarget">

    <Page.Resources>
        <common:BooleanToVisibilityConverter x:Key="IfTrueThenVisible" TrueValue="Visible"/>
        <common:BooleanToVisibilityConverter x:Key="IfFalseThenVisible" TrueValue="Collapsed"/>
        <common:BooleanNegationConverter x:Key="BooleanNegationConverter"/>
    </Page.Resources>

    <!--
        This grid acts as a root panel for the page that defines three rows:
        * Row 0 contains the standard share target header
        * Row 1 contains a TextBox for adding a Comment
        * Row 2 contains the standard share target footer
    -->
    <Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}">
        <Grid.ChildrenTransitions>
            <TransitionCollection>
                <EntranceThemeTransition/>
            </TransitionCollection>
        </Grid.ChildrenTransitions>

        <Grid Margin="40,20,40,60">
            <Grid.RowDefinitions>
                <RowDefinition Height="Auto"/>
                <RowDefinition Height="*"/>
                <RowDefinition Height="Auto"/>
            </Grid.RowDefinitions>
            <Grid.Resources>
                <Style TargetType="Border">
                    <Setter Property="BorderBrush" Value="{ThemeResource ListBoxBorderThemeBrush}"/>
                    <Setter Property="BorderThickness" Value="{ThemeResource ListBoxBorderThemeThickness}"/>
                </Style>
                <Style TargetType="TextBlock" BasedOn="{StaticResource BodyTextBlockStyle}">
                    <Setter Property="Foreground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                </Style>
                <Style TargetType="TextBlock" x:Name="SectionHeader" BasedOn="{StaticResource SubheaderTextBlockStyle}">
                    <Setter Property="Foreground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                    <Setter Property="Margin" Value="10,0,0,10"/>
                </Style>
            </Grid.Resources>

            <!-- The header displays metadata about the shared item -->
            <Grid Grid.Row="0" Grid.Column="0" >
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="*"/>
                </Grid.RowDefinitions>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>
                    
                <TextBlock Grid.Row="0" Grid.Column="0" Text="Title:" Style="{StaticResource SectionHeader}" />
                <TextBlock Grid.Row="0" Grid.Column="1" Grid.ColumnSpan="2" Text="{Binding Title}" Style="{StaticResource SectionHeader}" TextWrapping="NoWrap" />
                <Grid Grid.Row="1" Grid.Column="2" Margin="10,0,10,0">
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Grid.Column="0"
                                Text="Logo:"
                                HorizontalAlignment="Center"/>
                    <Grid Grid.Row="1" Grid.Column="0" Background="{Binding LogoBackground}" Margin="0,10,0,5" >
                        <Image Grid.Row="0" Grid.Column="0"
                                Source="{Binding Logo}"
                                Stretch="Uniform"
                                Visibility="{Binding ShowLogoImage, Converter={StaticResource IfTrueThenVisible}}"
                                VerticalAlignment="Center" HorizontalAlignment="Center"
                                Width="30" Height="30" Margin="20,0"/>
                    </Grid>
                </Grid>

                <Grid Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2" Margin="10,0,0,0">
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="10"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>

                    <TextBlock Grid.Row="1" Grid.Column="0" Text="Description:" />
                    <TextBlock Grid.Row="1" Grid.Column="2" Text="{Binding Description}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>

                    <TextBlock Grid.Row="2" Grid.Column="0" Text="Application Name:" />
                    <TextBlock Grid.Row="2" Grid.Column="2" Text="{Binding ApplicationName}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis"/>

                    <TextBlock Grid.Row="3" Grid.Column="0" Text="Application Listing:" />
                    <HyperlinkButton Grid.Row="3" Grid.Column="2"
                                NavigateUri="{Binding ApplicationListingUri}" 
                                Content="{Binding ContentSourceApplicationLink}" 
                                Style="{StaticResource TextBlockButtonStyle}"/>

                    <TextBlock Grid.Row="4" Grid.Column="0" Text="Application Link:" />
                    <HyperlinkButton Grid.Row="4" Grid.Column="2"
                                NavigateUri="{Binding ContentSourceApplicationLink}" 
                                Content="{Binding ContentSourceApplicationLink}" 
                                Style="{StaticResource TextBlockButtonStyle}"/>

                    <TextBlock Grid.Row="5" Grid.Column="0" Text="Web Link:" />
                    <HyperlinkButton Grid.Row="5" Grid.Column="2"
                                NavigateUri="{Binding ContentSourceWebLink}" 
                                Content="{Binding ContentSourceWebLink}"
                                Style="{StaticResource TextBlockButtonStyle}"/>

                    <TextBlock Grid.Row="6" Grid.Column="0" Text="QuickLink Id:"/>
                    <Grid Grid.Row="6" Grid.Column="2">
                        <Grid.ColumnDefinitions>
                            <ColumnDefinition Width="*"/>
                            <ColumnDefinition Width="Auto"/>
                        </Grid.ColumnDefinitions>
                        <TextBlock Grid.Column="0" Text="{Binding QuickLinkId}"/>
                        <Button Grid.Column="1" Content="Remove" IsEnabled ="{Binding LaunchedWithQuickLink}" Click="OnClickRemoveQuickLink"/>
                    </Grid>
                </Grid>
            </Grid>

            <Border Grid.Row="1">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="*"/>
                    </Grid.RowDefinitions>
                    <TextBlock Grid.Row="0" Text="Shared Content:"  Style="{StaticResource SectionHeader}"/>
                    <StackPanel Grid.Row="0" Margin="0,0,0,10" Orientation="Horizontal" HorizontalAlignment="Right" Visibility="{Binding ShowThumbnailImage, Converter={StaticResource IfTrueThenVisible}}">
                        <TextBlock Text="Thumbnail: "
                                   VerticalAlignment="Bottom"
                                   Style="{StaticResource BodyTextBlockStyle}"
                                   Foreground="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                        <Image Source="{Binding ThumbnailImage}"
                               Stretch="Uniform"
                               Width="30" Height="30"
                               Margin="10,0,0,0"/>
                    </StackPanel>

                    <ScrollViewer Grid.Row="1" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Auto">
                        <Grid Margin="0,0,20,0">
                            <Grid.RowDefinitions>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="Auto"/>
                                <ColumnDefinition Width="*"/>
                            </Grid.ColumnDefinitions>
                            <Grid.Resources>
                                <Style TargetType="TextBlock" BasedOn="{StaticResource CaptionTextBlockStyle}">
                                    <Setter Property="Margin" Value="10,0,0,10"/>
                                    <Setter Property="Foreground" Value="{ThemeResource ApplicationSecondaryForegroundThemeBrush}"/>
                                    <Setter Property="VerticalAlignment" Value="Center"/>
                                </Style>
                                <Style TargetType="WebView">
                                    <Setter Property="Margin" Value="10"/>
                                </Style>
                                <Style TargetType="Image">
                                    <Setter Property="Margin" Value="10"/>
                                </Style>
                                <Style TargetType="HyperlinkButton" BasedOn="{StaticResource TextBlockButtonStyle}">
                                    <Setter Property="Margin" Value="10"/>
                                </Style>
                                <Style TargetType="ListBox">
                                    <Setter Property="Margin" Value="10"/>
                                </Style>                            
                                <Style TargetType="TextBox">
                                    <Setter Property="Margin" Value="10"/>
                                    <Setter Property="IsReadOnly" Value="True"/>
                                </Style>
                            </Grid.Resources>

                            <TextBlock Grid.Row="0" Grid.Column="0" Text="Shared Text: " Visibility="{Binding IsTextShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="0" Grid.Column="1" Visibility="{Binding IsTextShared, Converter={StaticResource IfTrueThenVisible}}">
                                <TextBox IsReadOnly="True" Text="{Binding SharedText}"/>
                            </Grid>

                            <TextBlock Grid.Row="1" Grid.Column="0" Text="Shared RTF: " Visibility="{Binding IsRtfShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="1" Grid.Column="1" Visibility="{Binding IsRtfShared, Converter={StaticResource IfTrueThenVisible}}">
                                <TextBox IsReadOnly="True" Text="{Binding RTF}" />
                            </Grid>

                            <TextBlock Grid.Row="2" Grid.Column="0" Text="Shared HTML: " Visibility="{Binding IsHtmlShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="2" Grid.Column="1" Visibility="{Binding IsHtmlShared, Converter={StaticResource IfTrueThenVisible}}">
                                <WebView local:Extensions.SourceHtmlText="{Binding SharedHtml}" Height="180" Visibility="{Binding IsHtmlLoading, Converter={StaticResource IfFalseThenVisible}}"/>
                                <Grid Visibility="{Binding IsHtmlLoading, Converter={StaticResource IfTrueThenVisible}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="Loading" HorizontalAlignment="Center"/>
                                    <ProgressBar Grid.Row="1" IsIndeterminate="{Binding IsHtmlLoading}" HorizontalAlignment="Stretch" Height="20"/>
                                </Grid>
                            </Grid>

                            <TextBlock Grid.Row="3" Grid.Column="0" Text="Shared Bitmap: " Visibility="{Binding IsBitmapShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="3" Grid.Column="1" Visibility="{Binding IsBitmapShared, Converter={StaticResource IfTrueThenVisible}}">
                                <Image Source="{Binding SharedBitmap}" Stretch="Uniform" Width="80" Height="80" Visibility="{Binding IsBitmapLoading, Converter={StaticResource IfFalseThenVisible}}"/>
                                <Grid Visibility="{Binding IsBitmapLoading, Converter={StaticResource IfTrueThenVisible}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="Loading" HorizontalAlignment="Center"/>
                                    <ProgressBar Grid.Row="1" IsIndeterminate="{Binding IsBitmapLoading}" HorizontalAlignment="Stretch" Height="20"/>
                                </Grid>
                            </Grid>

                            <TextBlock Grid.Row="4" Grid.Column="0" Text="Shared Application Link:" Visibility="{Binding IsApplicationLinkShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="4" Grid.Column="1" Visibility="{Binding IsApplicationLinkShared, Converter={StaticResource IfTrueThenVisible}}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBox Grid.Column="0" Text="{Binding SharedApplicationLink}"/>
                                    <HyperlinkButton Grid.Column="1" NavigateUri="{Binding SharedApplicationLink}" Content="Go" />
                                </Grid>
                            </Grid>

                            <TextBlock Grid.Row="5" Grid.Column="0" Text="Shared Web Link:" Visibility="{Binding IsWebLinkShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="5" Grid.Column="1" Visibility="{Binding IsWebLinkShared, Converter={StaticResource IfTrueThenVisible}}">
                                <Grid>
                                    <Grid.ColumnDefinitions>
                                        <ColumnDefinition Width="*"/>
                                        <ColumnDefinition Width="Auto"/>
                                    </Grid.ColumnDefinitions>
                                    <TextBox Grid.Column="0" Text="{Binding SharedWebLink}"/>
                                    <HyperlinkButton Grid.Column="1" NavigateUri="{Binding SharedWebLink}" Content="Go" />
                                </Grid>
                            </Grid>

                            <TextBlock Grid.Row="6" Grid.Column="0" Text="Shared Storage Items:" Visibility="{Binding IsStorageItemsShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="6" Grid.Column="1" Visibility="{Binding IsStorageItemsShared, Converter={StaticResource IfTrueThenVisible}}">
                                <ListBox Height="80" ItemsSource="{Binding SharedStorageItems}" />
                            </Grid>

                            <TextBlock Grid.Row="7" Grid.Column="0" Text="Shared Custom Item:" Visibility="{Binding IsCustomItemShared, Converter={StaticResource IfTrueThenVisible}}"/>
                            <Grid Grid.Row="7" Grid.Column="1" Visibility="{Binding IsCustomItemShared, Converter={StaticResource IfTrueThenVisible}}">
                                <TextBox Text="{Binding SharedCustomItem}"
                                         Height="200" 
                                         AcceptsReturn="True" 
                                         ScrollViewer.VerticalScrollBarVisibility="Auto"
                                         Visibility="{Binding IsCustomItemLoading, Converter={StaticResource IfFalseThenVisible}}"/>
                                <Grid Visibility="{Binding IsCustomItemLoading, Converter={StaticResource IfTrueThenVisible}}">
                                    <Grid.RowDefinitions>
                                        <RowDefinition Height="Auto"/>
                                        <RowDefinition Height="*"/>
                                    </Grid.RowDefinitions>
                                    <TextBlock Grid.Row="0" Text="Loading" HorizontalAlignment="Center"/>
                                    <ProgressBar Grid.Row="1" IsIndeterminate="{Binding IsCustomItemLoading}" HorizontalAlignment="Stretch" Height="20"/>
                                </Grid>
                            </Grid>
                        </Grid>
                    </ScrollViewer>
                </Grid>
            </Border>

            <!-- Share target footer -->
            <Border Grid.Row="2" BorderThickness="0">
                <Grid>
                    <Grid.RowDefinitions>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                        <RowDefinition Height="Auto"/>
                    </Grid.RowDefinitions>
                    <Grid.ColumnDefinitions>
                        <ColumnDefinition Width="Auto"/>
                        <ColumnDefinition Width="*"/>
                    </Grid.ColumnDefinitions>
                    <Grid.Resources>
                        <Style TargetType="TextBox">
                            <Setter Property="Margin" Value="5"/>
                        </Style>
                        <Style TargetType="CheckBox">
                            <Setter Property="Margin" Value="5"/>
                        </Style>                
                    </Grid.Resources>
                    <Button Grid.Row="0" Grid.Column="0"
                            Content="Report Success"
                            IsEnabled="{Binding ProcessingSharedData, Converter={StaticResource BooleanNegationConverter}}"
                            HorizontalAlignment="Stretch"
                            Margin="5"
                            Click="OnReportSuccessClick"/>
                    <CheckBox Grid.Row="0" Grid.Column="1"
                              Content="Set QuickLink"
                              IsChecked="{Binding UseQuickLink, Mode=TwoWay}"/>
                    <TextBox Grid.Row="1" Grid.Column="1" PlaceholderText="QuickLink Id" Text="{Binding QuickLinkTag, Mode=TwoWay}" Visibility="{Binding UseQuickLink, Converter={StaticResource IfTrueThenVisible}}"/>
                    <TextBox Grid.Row="2" Grid.Column="1" PlaceholderText="QuickLink Title" Text="{Binding QuickLinkTitle, Mode=TwoWay}" Visibility="{Binding UseQuickLink, Converter={StaticResource IfTrueThenVisible}}"/>
                
                    <Button
                        Grid.Row="3" Grid.Column="0"
                        Content="Report Error"
                        IsEnabled="{Binding ProcessingSharedData, Converter={StaticResource BooleanNegationConverter}}"
                        HorizontalAlignment="Stretch"
                        Margin="5"
                        Click="OnReportErrorClick"/>
                    <TextBox Grid.Row="3" Grid.Column="1" PlaceholderText="Error message text" Text="{Binding ErrorMessage, Mode=TwoWay}"></TextBox>

                    <!--<CheckBox Content="Create Quicklink"/>
                    <ProgressRing
                        IsActive="{Binding ProcessingSharedData}"
                        MinWidth="20"
                        MinHeight="20"
                        HorizontalAlignment="Left"
                        VerticalAlignment="Top"
                        Margin="0,5,0,0"/>
                    <TextBlock
                        Text="Processing Shared Data&#x2026;"
                        Visibility="{Binding ProcessingSharedData, Converter={StaticResource IfTrueThenVisible}}"
                        HorizontalAlignment="Left"
                        Margin="25,0,0,0"
                        Style="{StaticResource BaseTextBlockStyle}"/>

                    <Button Content="Foobar"></Button>-->
                </Grid>
            </Border>
        </Grid>
    </Grid>
</Page>
